<!--

    Copyright 2010 Guadaltel, S.A.

    Licensed under the EUPL, Version 1.1 or - as soon they
    will be approved by the European Commission - subsequent
    versions of the EUPL (the "Licence");
    you may not use this work except in compliance with the
    Licence.
    You may obtain a copy of the Licence at:

    http://ec.europa.eu/idabc/eupl

    Unless required by applicable law or agreed to in
    writing, software distributed under the Licence is
    distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
    express or implied.
    See the Licence for the specific language governing
    permissions and limitations under the Licence.

-->

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:a="http://richfaces.org/a4j" template="layout/acceso.xhtml"
	xmlns:rich="http://richfaces.org/rich">


	<rich:tabPanel>
		<rich:tab label="Gestión usuarios">

			<h:form>
				<f:facet name="header">
					<h:outputText
						value="Creación y modificacion de los usuarios" />
				</f:facet>
				<h:panelGrid columns="3" name="botones">
					<a:commandLink ajaxSingle="true" id="urlnuevoUsua" reRender="new"
						action="#{extraeUsuariosBean.cargarFormuNuevo}"
						style="text-align: right;">
						<h:graphicImage value="temas/iconos/16x16/document-new.png"
							style="border:0" />
						<h:outputText value="Nuevo" />
					</a:commandLink>


					<a:commandLink ajaxSingle="true" id="urlbuscarRol" reRender="new"
						action="#{extraeUsuariosBean.cargarFormuBuscar}">
						<h:graphicImage value="temas/tablon/iconos/system-search.png"
							style="border:0" />
						<h:outputText value="buscar" />
					</a:commandLink>

					<a:commandLink ajaxSingle="true" id="urlrecargar" reRender="aaa"
						action="#{extraeUsuariosBean.cargarFormulario}">
						<h:graphicImage value="temas/iconos/16x16/view-refresh.png"
							style="border:0" />
						<h:outputText value="Recargar usuarios" />
					</a:commandLink>
				</h:panelGrid>
			</h:form>

			<h:form>
				<rich:dataTable value="#{listUsuarios}" var="usu" rows="10"
					id="table" width="100%" border="1px" autosize="true">

					<f:facet name="header">
						<rich:columnGroup>
							<rich:column colspan="9">
								<h:outputText value="Usuarios" />
							</rich:column>
						</rich:columnGroup>
					</f:facet>
					<rich:column sortBy="#{usu.TNombre}">
						<f:facet name="header">
							<h:outputText value="Nombre" />
						</f:facet>
						<h:outputText value="#{usu.TNombre}" />
					</rich:column>

					<rich:column sortBy="#{usu.TApellido1}">
						<f:facet name="header">
							<h:outputText value="Apellido 1" />
						</f:facet>
						<h:outputText value="#{usu.TApellido1}" />
					</rich:column>

					<rich:column sortBy="#{usu.TApellido2}">
						<f:facet name="header">
							<h:outputText value="Apellido 2" />
						</f:facet>
						<h:outputText value="#{usu.TApellido2}" />
					</rich:column>

					<rich:column>
						<f:facet name="header">
							<h:outputText value="Identificador" />
						</f:facet>
						<h:outputText value="#{usu.TIdentificador}" />
					</rich:column>

					<rich:column orderBy="#{usu.tbTiposIdentificador.CAbreviatura}">
						<f:facet name="header">
							<h:outputText value="Tipo Identificador" />
						</f:facet>
						<h:outputText value="#{usu.tbTiposIdentificador.CAbreviatura}" />
					</rich:column>

					<rich:column sortBy="#{usu.LVigente}">
						<f:facet name="header">
							<h:outputText value="Vigente" />
						</f:facet>
						<h:outputText value="#{usu.LVigente}" />
					</rich:column>

					<rich:column sortBy="#{usu.LAdministrador}">
						<f:facet name="header">
							<h:outputText value="Administrador" />
						</f:facet>
						<h:outputText value="#{usu.LAdministrador}" />
					</rich:column>


					<rich:column>
						<f:facet name="header">
							<h:outputText value="Email" />
						</f:facet>
						<h:outputText value="#{usu.TEmail}" />
					</rich:column>


					<rich:column>
						<f:facet name="header">
							<h:outputText value="Acciones" />
						</f:facet>
						<a:commandLink ajaxSingle="true" id="urlEditar" title="Editar"
							reRender="editPanel" action="#{extraeUsuariosBean.modificar(usu)}"
							oncomplete="#{rich:component('editPanel')}.show()">
							<h:graphicImage value="temas/tablon/iconos/edit.png"
								style="border:0" />
						</a:commandLink>

						<a:commandLink ajaxSingle="true" id="urlborrar" title="Eliminar"
							reRender="borraPanel" action="#{extraeUsuariosBean.cargarRol(usu)}"
							oncomplete="#{rich:component('borraPanel')}.show()">
							<h:graphicImage value="temas/tablon/iconos/delete.gif"
								style="border:0" />
						</a:commandLink>

					</rich:column>
					<f:facet name="footer">
						<rich:datascroller renderIfSinglePage="false" maxPages="8" />
					</f:facet>
				</rich:dataTable>
			</h:form>


		</rich:tab>
	</rich:tabPanel>


	<rich:modalPanel id="editPanel" width="350">


		<f:facet name="header">
			<h:panelGroup>
				<h:outputText value="Modificar rol"></h:outputText>
			</h:panelGroup>
		</f:facet>

		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="temas/iconos/16x16/emblem-unreadable.png"
					id="hidelink" styleClass="hidelink" />
				<rich:componentControl for="editPanel" attachTo="hidelink"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<h:panelGrid columns="2" cellspacing="10px">

				<h:outputLabel value="Codigo Rol" for="codigoRolInput" />
				<h:inputText value="#{extraeUsuariosBean.tapellido1Mod}"
					id="codigoRolInput" />

				<h:outputLabel value="Descripcion Rol" for="textoRolInput" />
				<h:inputText value="#{extraeUsuariosBean.tnombreMod}"
					id="textoRolInput" />

				<a:commandButton value="Modificar"
					action="#{extraeUsuariosBean.guardaModif}"
					oncomplete="Richfaces.hideModalPanel('editPanel')" reRender="aaa" />

			</h:panelGrid>
		</h:form>
	</rich:modalPanel>



	<rich:modalPanel id="borraPanel" autosize="true">


		<f:facet name="header">
			<h:panelGroup>
				<h:outputText value="Eliminar Rol"></h:outputText>
			</h:panelGroup>
		</f:facet>

		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="temas/iconos/16x16/emblem-unreadable.png"
					id="hidealink" styleClass="hidelink" />
				<rich:componentControl for="borraPanel" attachTo="hidealink"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<h:outputLabel value="¿Seguro que desea eliminar el rol?"
				for="textoRolInput" />
			<h:panelGrid columns="2" cellspacing="20px">


				<a:commandButton value="Sí" action="#{extraeUsuariosBean.eliminar}"
					oncomplete="Richfaces.hideModalPanel('borraPanel')" reRender="aaa" />

				<a:commandButton value="No"
					oncomplete="Richfaces.hideModalPanel('borraPanel')" reRender="aaa" />



			</h:panelGrid>
		</h:form>
	</rich:modalPanel>


</ui:composition>